/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bionic.socialNet.dao.implementations;

import com.bionic.shsc.dao.interfaces.IProfileDAO;
import com.bionic.socialNet.entities.ProfileData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Ann
 */
public class MySQLProfile extends QueryExecutor implements IProfileDAO {

    @Override
    public ProfileData findProfile(int userID) {
        // FIND_PROFILE
        ProfileData profile = new ProfileData();
        String querySQL = "SELECT *  FROM profile WHERE user_id = ? ";
        try {
            PreparedStatement pstmt = query.getConnection().prepareStatement(querySQL);
            pstmt.setInt(1, userID);
            ResultSet results = pstmt.executeQuery();
            while (results.next()) {
                profile.setAbout(results.getString("about"));
                profile.setFullname(results.getString("full_name"));                
                profile.getAddress().setStreet(results.getString("street"));
                profile.getAddress().setStreet(results.getString("house_num"));
                profile.getAddress().setStreet(results.getString("zip")); 
                profile.setUser_id(results.getInt("user_id"));
            }
            return profile;
        } catch (SQLException ex) {
            Logger.getLogger(MySQLQuery.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }

    }

    @Override
    public boolean updateProfile(ProfileData profileData) {
        //UPDATE_PROFILE
        // nickname,fullname,birthday,sex,about,photo
        return false;
        //query.executeUpdateStatement(String.format(UPDATE_PROFILE, profileData.getNickname(),
        //profileData.getFullname(), profileData.getBirthday(), profileData.getSex(), profileData.getAbout()));
    }

    @Override
    public boolean createProfile(ProfileData profileData) {
        return false;//query.executeInsertStatement(String.format(INSERT_PROFILE, profileData.getUser_id(),
        //profileData.getNickname(), profileData.getFullname(), profileData.getBirthday(), profileData.getSex(), profileData.getAbout()));
    }
}
